<?php
/**
 * @name ErrorController
 * @desc 错误控制器, 在发生未捕获的异常时刻被调用
 * @see http://www.php.net/manual/en/yaf-dispatcher.catchexception.php
 * @author Lenovo
 */
class ErrorController extends Yaf_Controller_Abstract {

	public function errorAction($exception) {
		 $uri = $this->getRequest()->uri;
		 $data = [
		 	'file'=>$exception->getFile(),
		 	'line'=>$exception->getLine(),
		 	'uri' => $uri,
		 	'trace'=>$exception->getTrace()
		 ];
		 error_system_log($exception);
		 header('Content-type: application/json');
		 echo json_encode(
			[
				'code'=>422,
				'message' => $exception->getMessage(),
				'data' => $data
			]
		 );
	     exit();
	}
}
